function refresh(){
    $("#dataTable").bootstrapTable("removeAll");
    $("#dataTable").bootstrapTable('refresh');
}
function yesOperator(){
    console.log("====yesOperator=====");
    var retValue=selectData();
    return retValue;
}
function selectData(){

    var len = $("#dataTable input:checked").length;

    if (len == 0) {
        //未选中数据提示框
        layer.msg('请选择数据',  {time:2500});

    } else {

        var rows= $("#dataTable").bootstrapTable('getSelections');
        var rowIds = [];
        var ret={};
        return rows[0];
    }
}
//搜索以前将页码换成第一页
function searchInit(){
    var options=$("#dataTable").bootstrapTable("getOptions");
    options.pageNumber=1;
    $("#dataTable").bootstrapTable('refreshOptions',options);
}
$(function () {
    $("#serachBtn").click(function(){
        searchInit();
        refresh();
    });
    $('#serachBtn').bind('keypress',function(e){
        searchInit();

        if(e.keyCode == 13){
            refresh();
        }
    });

    $('#cleanCode').bind('keypress',function(e){


        if(e.keyCode == 13){
            searchInit();
            refresh();
        }
    });
    $('#cleanName').bind('keypress',function(e){


        if(e.keyCode == 13){
            searchInit();
            refresh();
        }
    });

    $("#searchCondition").focus();
    //渲染表格
    var columns = clearRuleList.columnsInit();
    var table = clearRuleList.gridInit(columns);
    var datas = clearRuleList.dataInit();
    $("#dataTable").bootstrapTable("append",datas);
})
;(function(undefined) {
    "use strict"
    var _global;

    function result(args,fn){
        var argsArr = Array.prototype.slice.call(args);
        if(argsArr.length > 0){
            return argsArr.reduce(fn);
        } else {
            return 0;
        }
    }
    var clearRuleList = {
        columnsInit:function(){
            return  [{
                field: 'radio',
                radio: true,
                align: 'center',
                valign: 'middle'
            }, {
                field: 'id',
                title: '序号',
                formatter: function (value, row, index) {
                    return     index+1 ;
                }
            },
                {field:"cleanCode",title:"清理编码" },
                {field:"cleanName",title:"清理名称" },
                {field:"rowSort",title:"排序号" },
                {field:"remarks",title:"备注" },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        if(value == '1'){
                            return [
                                '<span class="sys-type-bg pro-status-green">正常</span>'
                            ].join('');
                        }
                        return [
                            '<span class="sys-type-bg pro-status-red">停用</span>'
                        ].join('');

                    }

                }]
        },
        gridInit:function(columns){
            return $("#dataTable").bootstrapTable({
                method: "post",
                contentType: "application/x-www-form-urlencoded",
                url: $$.restServerUrl + '/bootstrap/basegrid/IotCleanBusiness/list',
                columns: columns,
                undefinedText: '-',
                striped: 'true',
                classes: 'table table-hover qxttable',
                pagination: 'true',
                clickToSelect: true,
                singleSelect: false,
                sidePagination: "server",
                queryParamsType: "page",
                sortSide: 'client',
                sortable: true,
                pageNumber: 1,
                pageSize: 5,
                idField: 'id',
                silentSort: true,
                pageList: [
                	10, 20, 50, 100
                ],
                onClickRow: function (row, $element, field) {
                    $("#dataTable").bootstrapTable("uncheckAll");
                },
                queryParams: function queryParams(params) {   //设置查询参数

                    var args = {};
                    args.c_cleanCode_7=$("#cleanCode").val();
                    args.c_cleanName_7=$("#cleanName").val();
                    args.page = params.pageNumber - 1; //    params.pageNumber
                    args.pageSize = params.pageSize;     //params.pageSize
                    args.isPage = 1;
                    //args.order=orderStr;
                    var paramStr = JSON.stringify(args);

                    //alert(params.pageNumber+":"+params.pageSize);
                    //alert(orderStr);
                    var param = {
                        params: paramStr
                    };
                    return param;
                }
            })

        },
        dataInit:function(){
            return  []
        }
    }

    // 将插件对象暴露给全局对象
    _global = (function(){ return this || (0, eval)('this'); }());
    if (typeof module !== "undefined" && module.exports) {
        module.exports = clearRuleList;
    } else if (typeof define === "function" && define.amd) {
        define(function(){return clearRuleList;});
    } else {
        !('plugin' in _global) && (_global.clearRuleList = clearRuleList);
    }
}());